package ar.edu.utn.kohonen.main;

import org.generation5.nn.KohonenNN;

import ar.edu.utn.kohonen.main.KohonenImageClassifier.KohonenImageTrainer;

public class EntrenadorDeImagen {
	  public double[][] featureVectors;
      private int currentStep = 0;
      KohonenNN kohonenNetwork;

      public KohonenNN getKohonenNetwork() {
		return kohonenNetwork;
	}

	public void setKohonenNetwork(KohonenNN kohonenNetwork) {
		this.kohonenNetwork = kohonenNetwork;
	}

	public double[] getTrainingPoint() {
          return featureVectors[currentStep++ % featureVectors.length];
      }
      
      private void trainNetwork()
      {
  		/*
          if (featureVectors == null || inputImages == null)
              throw new NullPointerException("either no input images or no features created.");
          */
          System.err.print("Training neural network...");

          KohonenImageTrainer train = new KohonenImageTrainer();
          train.featureVectors = featureVectors;
          train.setNetwork(kohonenNetwork);
          train.init();
          train.setPhases(inputImages.length * 15, inputImages.length * 5);

          kohonenNetwork.initialize(0.0, 1.0);

          do {
              train.doStep();
          } while (!train.isComplete());

          System.err.println("done.");    
          
      }
}
